package com.liupei.service.impl;

import com.liupei.entity.User;
import com.liupei.feign.ISysSeateFeign;
import com.liupei.mapper.UserMapper;
import com.liupei.pojo.Sys;
import com.liupei.service.UserService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    @Resource
    private ISysSeateFeign iSysSeateFeign;



    @Override
    @GlobalTransactional(name = "fsp-create-order",rollbackFor = Exception.class)
    public int add(User user) {
        Map<String, String> map = iSysSeateFeign.addSys();
        user.setSysId(map.get("sysId"));
        int i = 10/0;
        int insert = userMapper.insert(user);
        return insert;
    }
}
